//
//  AFNDataBlock.m
//  太平洋电脑
//
//  Created by dlios on 15-8-24.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DestAFNDataBlock.h"

@implementation DestAFNDataBlock



+(void)string:(NSString *)string AFNData:(AFNData)block AFNData1:(AFNData)myblock
{
    
    AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
//    NSString *url_string = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *url_string= [NSString stringWithFormat:@"%@",string];
   // [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  代表支持所有的接口类型
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    
    [manager.requestSerializer setValue: @"bt_devid=i_d63d4b42f2d65111c76a3f192a876f882fd4c5dceef451cf2e9cd6a724aeec9f07c223b6; Hm_lpvt_39ccc5353de4e1969b414e80e516d5a7=1445242129; Hm_lvt_39ccc5353de4e1969b414e80e516d5a7=1445242129; sessionid=8cc1506d292b5b17241733e981e49a7e" forHTTPHeaderField:@"Cookie"];
    [manager.requestSerializer setValue: @"BreadTrip/6.1.1/zh" forHTTPHeaderField:@"User-Agent"];
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        [netWorkManager stopMonitoring];
            block(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"失败==== %@",error);
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//            UIAlertView *AlerView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"当前网络不好" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//            [AlerView show];
           
            myblock(nil);
            
        });
    }];
}

@end
